﻿using System;
using MDK.Device.Components;

namespace MDK.Device.Devices
{
    public class BackDevice
    {
        public BackDevice(IPlcDevice device)
        {
            Device = device;
            InitializeComponents();
        }
        public IPlcDevice Device { get; }
        public IActuator Belt { get; private set; }
        public ISensor BeltEndSensor { get; private set; }
        public IAxle X { get; private set; }
        public IAxle Y { get; private set; }
        public IAxle SZ { get; private set; }
        public ISwitch Lamp { get; private set; }
        public ISwitch UVLamp { get; private set; }
        public ISwitch Finger { get; private set; }
        public ISwitch Laminar { get; private set; }
        public ISensor[] CarrierSensors { get; private set; }
        public IScanner FingerScanner { get; private set; }
        public IUncap Uncap { get; private set; }
        public IRotator FingerRotator { get; private set; }
        public ISensor FingerCheckSensor { get; private set; }
        public ICamera Camera { get; private set; }
        public ISensor []BackManSersors { get; private set; }
        public ISensor[] AusbioSersors { get; private set; }
        public ISensor[] TecanSersors { get; private set; }
        private void InitializeComponents()
        {
            //CarrierSensors = new ISensor[]
            //{
            //    new Sensor(Device, "X26"), new Sensor(Device, "X27"), new Sensor(Device, "X30"), new Sensor(Device, "X31"), new Sensor(Device, "X32"), new Sensor(Device, "X33"), new Sensor(Device, "X34"), new Sensor(Device, "X35"),
            //    new Sensor(Device, "X36"), new Sensor(Device, "X37"), new Sensor(Device, "X40"), new Sensor(Device, "X41"), new Sensor(Device, "X42"), new Sensor(Device, "X43"), new Sensor(Device, "X44"), new Sensor(Device, "X45"),
            //    new Sensor(Device, "X46"), new Sensor(Device, "X47")
            //};

            BackManSersors = new ISensor[]
            {
                new Sensor(Device,"X37"), new Sensor(Device,"X45"),new Sensor(Device,"X36"),new Sensor(Device,"X44"),new Sensor(Device,"X35"),new Sensor(Device,"X43"),
                new Sensor(Device,"X34"),new Sensor(Device,"X42"),new Sensor(Device,"X33"),new Sensor(Device,"X41"),new Sensor(Device,"X32"),new Sensor(Device,"X40"),
            };

            TecanSersors  = new ISensor[]
            {
                new Sensor(Device,"X62"), new Sensor(Device,"X61"),new Sensor(Device,"X60"),new Sensor(Device,"X51"),new Sensor(Device,"X50"),new Sensor(Device,"X47"),
                new Sensor(Device,"X46")
            };

            AusbioSersors = new ISensor[]
            {
                new Sensor(Device,"X31"), new Sensor(Device,"X30"),new Sensor(Device,"X27"),new Sensor(Device,"X26")
            };

            X = new StdAxle(Device, "DD34", "DD100", "L0", "M30", "M358", "M20", "M21", "DD36", "M350", "M356", "D7", "X21", "X22", "X20","M359");
            Y = new StdAxle(Device, "DD38", "DD102", "L1", "M32", "M362", "M22", "M23", "DD40", "M352", "M360", "D10", "X24", "X23", "X25","M363");
            SZ = new LocationAxle(Device, new PlcAddress[] { "M26", "M27", "M28", "M37" }, "D18", "M36", "M29", "X7", "X4");
            Finger = new DoubleBitSwitch(Device, "M69", "M70");
            Belt = new DelayActuator(Device, "M268", "M269", "M270");
            BeltEndSensor = new Sensor(Device, "X16");
            Lamp = new Switch(Device, "M175");
            UVLamp = new Switch(Device, "M174");
            Laminar = new Switch(Device, "M173");
            FingerRotator = new Rotator(Device, "M54", "M45", "DD1004", "M147", "M157", "DD1002", "M171", "M172", "M63");
            Uncap = new Uncap(Device, "M9", "M19", "M67", "M68", "X55", "X57");
            FingerCheckSensor = new Sensor(Device, "X100");
        }
    }
}